name: On Label
on:
  issues:
    types: [labeled]

jobs:
  main:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Actions
        uses: actions/checkout@v4
        with:
          repository: "microsoft/vscode-github-triage-actions"
          ref: stable
          path: ./actions
      - name: Install Actions
        run: npm install --production --prefix ./actions

      # source of truth in ./author-verified.yml
      - name: Run Author Verified
        if: contains(github.event.issue.labels.*.name, 'author-verification-requested') && contains(github.event.issue.labels.*.name, 'insiders-released')
        uses: ./actions/author-verified
        with:
          appInsightsKey: ${{secrets.TRIAGE_ACTIONS_APP_INSIGHTS}}
          token: ${{secrets.VSCODE_ISSUE_TRIAGE_BOT_PAT}}
          requestVerificationComment: "This bug has been fixed in the latest release of [VS Code Insiders](https://code.visualstudio.com/insiders/)!\n\n@${author}, you can help us out by commenting `/verified` if things are now working as expected.\n\nIf things still don't seem right, please ensure you're on version ${commit} of Insiders (today's or later - you can use `Help: About` in the command palette to check), and leave a comment letting us know what isn't working as expected.\n\nHappy Coding!"
          releasedLabel: insiders-released
          verifiedLabel: verified
          authorVerificationRequestedLabel: author-verification-requested


      # also make changes in ./on-comment.yml
      - name: Run Commands
        uses: ./actions/commands
        with:
          appInsightsKey: ${{secrets.TRIAGE_ACTIONS_APP_INSIGHTS}}
          token: ${{secrets.VSCODE_ISSUE_TRIAGE_BOT_PAT}}
          config-path: commands

      # source of truth in ./feature-request.yml
      - name: Run Feature Request Manager
        if: contains(github.event.issue.labels.*.name, 'feature-request')
        uses: ./actions/feature-request
        with:
          appInsightsKey: ${{secrets.TRIAGE_ACTIONS_APP_INSIGHTS}}
          token: ${{secrets.VSCODE_ISSUE_TRIAGE_BOT_PAT}}
          candidateMilestoneID: 107
          candidateMilestoneName: Backlog Candidates
          backlogMilestoneID: 8
          featureRequestLabel: feature-request
          upvotesRequired: 20
          numCommentsOverride: 20
          initComment: "This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our [documentation](https://aka.ms/vscode-issue-lifecycle).\n\nHappy Coding!"
          warnComment: "This feature request has not yet received the 20 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our [documentation](https://aka.ms/vscode-issue-lifecycle).\n\nHappy Coding"
          acceptComment: ":slightly_smiling_face: This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our [documentation](https://aka.ms/vscode-issue-lifecycle).\n\nHappy Coding!"
          rejectComment: ":slightly_frowning_face: In the last 60 days, this feature request has received less than 20 community upvotes and we closed it. Still a big Thank You to you for taking the time to create this issue! To learn more about how we handle feature requests, please see our [documentation](https://aka.ms/vscode-issue-lifecycle).\n\nHappy Coding!"
          warnDays: 10
          closeDays: 60
          milestoneDelaySeconds: 60

      # source of truth in ./test-plan-item-validator.yml
      - name: Run Test Plan Item Validator
        if: contains(github.event.issue.labels.*.name, 'testplan-item') || contains(github.event.issue.labels.*.name, 'invalid-testplan-item')
        uses: ./actions/test-plan-item-validator
        with:
          token: ${{secrets.VSCODE_ISSUE_TRIAGE_BOT_PAT}}
          refLabel: on-testplan
          label: testplan-item
          invalidLabel: invalid-testplan-item
          comment: Invalid test plan item. See errors below and the [test plan item spec](https://github.com/microsoft/vscode/wiki/Writing-Test-Plan-Items) for more information. This comment will go away when the issues are resolved.

      # source of truth in ./english-please.yml
      - name: Run English Please
        if: contains(github.event.issue.labels.*.name, '*english-please')
        uses: ./actions/english-please
        with:
          appInsightsKey: ${{secrets.TRIAGE_ACTIONS_APP_INSIGHTS}}
          token: ${{secrets.VSCODE_ISSUE_TRIAGE_BOT_PAT}}
          cognitiveServicesAPIKey: ${{secrets.AZURE_TEXT_TRANSLATOR_KEY}}
          nonEnglishLabel: "*english-please"
          needsMoreInfoLabel: "info-needed"
          translatorRequestedLabelPrefix: "translation-required-"
          translatorRequestedLabelColor: "c29cff"
